﻿function ok(sender, e) {
    $find('ModalPopupExtenderLogin').hide();
    __doPostBack('LoginBtn', e);
}
function okJoin(sender, e) {
    $find('ModalPopupExtenderSignup').hide();
    __doPostBack('JoinBtn', e);
}
function OnKeyPress(args) {
    if (args.keyCode == Sys.UI.Key.esc) {
        $find("ModalPopupExtenderLogin").hide();
    }
}
function body_onkeydown() {
    if (event.keyCode == 13 || event.keyCode == 27) {
        var _defaultButtonName = getDefautButtonName(event.keyCode == 13 ? "submitButton" : "cancelButton");
        var frm = document.forms[0];
        if (frm && document.all(_defaultButtonName)) {
            document.all(_defaultButtonName).click();
        }
    }
}

function getDefautButtonName(className) {
    var _defaultButtonName = "";
    var children = document.getElementsByTagName("input");
    for (var i = 0; i < children.length; i++) {
        var child = children[i];
        var btnAction = child.buttonAction;
        if (btnAction == className) {
            _defaultButtonName = child.id;
            break;
        }
    }
    return _defaultButtonName;
}